home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / userlib / holm_def.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-06  |  3.7 KB  |  133 lines

  1. /*
  2. Initialize all parameters for a given dynamical system to be installed
  3. Parameters are assigned to the default values before this program is called.
  4. -----------------------------------------------------------------------
  5. This is a GENERIC subroutine. If you want, you can change
  6. the name string "userds0" to a proper one globally in this program
  7. but then you need to change the same strings in the header file defining
  8. the current class of dynamical systems.
  9. */
  10.  
  11. /*
  12. Example 1: map with periodic variable
  13. */
  14. int userds0_init()
  15. {
  16.     extern int (*f_p)(),userds0_f(),(*func_p)(),userds0_func();
  17.     extern int var_dim,func_dim,param_dim;
  18.     extern int mapping_on,inverse_on,fderiv_on,enable_polar,enable_period;
  19.     extern double *param,*param_min,*param_max,*func,*func_min,*func_max;
  20.     extern double *var_i,*var_polar_i,*var_min,*var_max,*var_polar_min,*var_polar_max;
  21.     extern double *period_len,pi;
  22.     extern char *title_label,**var_label,**var_polar_label,**param_label,**func_label;
  23.  
  24.     /* title label */
  25.     title_label = "Chandra Flow";
  26.  
  27.     /* mapping toggle: 1: map 0: vector field */
  28.     mapping_on = 0;
  29.     /* inverse toggle: vector field: always 1,
  30.        maps: 1=explicit inverse is defined, 0=otherwise  */     /*  mrm (2/6/90 )  */
  31.     inverse_on = 1;
  32.     /* jacobian toggle: 1=Jacobian is explicitly given, 0=otherwise */
  33.     fderiv_on = 0;
  34.     /* polar toggle: 1=enable polar coordinate feature, 0=otherwise */
  35.     enable_polar = 0;
  36.     /* period toggle: 1=enable periodicity of phase space, 0=otherwise */
  37.     enable_period = 1;
  38.  
  39.     /* phase space dimension */
  40.     var_dim = 3;
  41.     /* parameter space dimension */
  42.     param_dim = 1;
  43.     /* function space dimension */
  44.     func_dim = 2;
  45.  
  46.     (void) malloc_init();
  47.  
  48.     /*periodicity of phase space variables (DIM=var_dim)*/
  49.     /* do not have to be defined if enable_period = 0 */
  50.     period_len[0] =1;
  51.     period_len[1] =1;
  52.     period_len[2] =1;
  53.  
  54.     /* primary phase space variable label (DIM=var_dim)*/
  55.     var_label[0] = "x";
  56.     var_label[1] = "y";
  57.     var_label[2] = "z";
  58.     /* seconsary phase space variable label (DIM=param_dim)*/
  59.     var_polar_label[0] = "~";
  60.     var_polar_label[1] = "~";
  61.     
  62.     /* parameter variable label (DIM=param_dim)*/
  63.     param_label[0] = "k";
  64.     /* function variable label (DIM=func_dim)*/
  65.     func_label[0] = "F1";
  66.     func_label[1] = "F2";
  67.  
  68.     /* starting parameter values (DIM=param_dim)*/
  69.     param[0] = 2;
  70.  
  71.     /* starting primary phase space variable values (DIM=param_dim)*/
  72.     var_i[0] = 1.5;
  73.     var_i[1] = 1.5;
  74.     var_i[2] = 0.001;
  75.     /* starting seconsary phase space variable values (DIM=param_dim)*/
  76.     /* do not have to be defined if enable_polar = 0 */
  77.     var_polar_i[0] = 0;
  78.     var_polar_i[1] = 0;
  79.  
  80.     /* starting bounds of parameter window box */
  81.     param_min[0]= 0; param_max[0]= 10;
  82.  
  83.     /* starting bounds of primary phase space window box */
  84.     var_min[0]= 0; var_max[0]= 1;
  85.     var_min[1]= 0; var_max[1]= 1;
  86.     var_min[2]= 0; var_max[2]= 1;
  87.  
  88.     /* starting bounds of secondary phase space window box */
  89.     /* do not have to be defined if enable_polar = 0 */
  90.     var_polar_min[0]= -5; var_polar_max[0]= 5;
  91.     var_polar_min[1]= -5; var_polar_max[1]= 5;
  92.  
  93.     /* dynamical system and function pointer assignments */
  94.     f_p = userds0_f;
  95.     func_p = userds0_func;
  96. }
  97. /*
  98. first user dynamical system
  99. */
  100.     
  101. int userds0_f(f,index,x,p,t,dim)
  102. int index,dim;
  103. double f[],x[],p[],t;
  104. {
  105.     double sx,cx,sy,cy,sz,cz,sin(),cos();
  106.     extern double twopi;
  107.  
  108.     sx = sin(twopi * x[0]);
  109.     sy = sin(twopi * x[1]);
  110.     sz = sin(twopi * x[2]);
  111.     cx = cos(twopi * x[0]);
  112.     cy = cos(twopi * x[1]);
  113.     cz = cos(twopi * x[2]);
  114.     f[0] = - (sx*cy + p[0]*p[0]*cx*sy)*cz;
  115.     f[1] = - (cx * sy - p[0]*p[0] *sx * cy) * cz;
  116.     f[2] = 2. * cx * cy * sz;
  117. }
  118. /*
  119. first user function subroutine
  120. */
  121.  
  122. int userds0_func(f,x,p,t,dim)
  123. double f[],x[],p[],t;
  124. int dim;
  125. {
  126.     double sx,cx,sy,cy,sz,cz,sin(),cos();
  127.     sx = sin(twopi * x[0]);
  128.     sy = sin(twopi * x[1]);
  129.     sz = sin(twopi * x[2]);
  130.     f[0] = sx * sy * sz;
  131.     f[1] = 0;
  132. }
  133.